package com.photographysharing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.photographysharing.entity.Categories;
import com.photographysharing.entity.ReportTypes;
import com.photographysharing.request.SelectByPaging;
import com.photographysharing.response.DatasResponse;
import com.photographysharing.service.ReportTypesService;
import com.photographysharing.mapper.ReportTypesMapper;
import org.springframework.stereotype.Service;

/**
* @author Z
* @description 针对表【report_types】的数据库操作Service实现
* @createDate 2024-05-14 21:15:11
*/
@Service
public class ReportTypesServiceImpl extends ServiceImpl<ReportTypesMapper, ReportTypes>
    implements ReportTypesService{

    private ReportTypesMapper reportTypesMapper;

    public ReportTypesServiceImpl(ReportTypesMapper reportTypesMapper) {
        this.reportTypesMapper = reportTypesMapper;
    }


    @Override
    public DatasResponse<ReportTypes> selectByPag(SelectByPaging pag) {
        int index = pag.getIndex();
        int size = pag.getSize();
        String name = pag.getSearchName();
        IPage<ReportTypes> page = new Page<>(index,size);
        QueryWrapper<ReportTypes> qw = new QueryWrapper<>();
        if(name != null && name !=""){
            qw.like("name",name);
        }
        IPage<ReportTypes> pages = reportTypesMapper.selectPage(page,qw);
        return new DatasResponse<ReportTypes>((int)pages.getTotal(),pages.getRecords());
    }
}




